package com.stream;

import com.pojo.User;

import javax.lang.model.element.VariableElement;
import java.rmi.ServerError;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @Author: 许磊磊
 * @Date: 2022/10/17 19:32
 * @Version 1.0
 */
public class StreamTest {
    public static void main(String[] args) {
        ArrayList<User> list = new ArrayList<>();
        for (int i = 0; i < 20; i++) {
            User user = new User();
            user.setAge(10 + i);
            user.setName(("zhangsan" + i).toCharArray());
            user.setUid(String.valueOf(UUID.randomUUID()));
            list.add(user);
        }

//        List<User> list1 =  list.stream().filter(s -> s.getAge() > 18).collect(Collectors.toList());
//        System.err.println(list1);

//        list.stream().skip(2).limit(3).forEach(System.err::println);
//        System.err.println(list.stream().count());

        System.err.println(list.stream().limit(2).peek(System.err::println)
                .min((s1, s2) -> s1.getAge() + s2.getAge()));
    }


}
